﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection;
using Pixysoft.Weblications.Sango.Dao;
using Pixysoft.Weblications.Sango.Mission;
using Pixysoft.Weblications.Sango.Protocol.mission;
using Pixysoft.Weblications.Sango.Protocol;

namespace Pixysoft.Weblications.Sango.Command.mission
{
    partial class SangoMissionHandler
    {
        public mission_mainlist mission_mainlist()
        {
            string userCode = SangoManager.Authentication();

            mission_mainlist response = ReflectionManager.CreatePojo<mission_mainlist>();
            response.Succeed = false;

            List<Entities.Usr_Mainmission> list = MissionDao.getUsrMainMissions(userCode);

            IEntityNoebeTransaction command = SettingHelper.EntityTransaction;

            command.Begin(delegate()
            {
                foreach (Entities.Usr_Mainmission mission in MainMissionFactory.handle(userCode, list))
                {
                    command.Update(mission);
                }

                command.Commit();
            });

            response.list = MissionFacade.ToMissions(list);
            response.Succeed = true;
            return response;
        }


    }
    public interface mission_mainlist : ISangoResponse
    {
        List<mission_main> list { get;set;}
    }
}
